package cate.game.role.bag.prop.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBBag;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@ClientMsg(title = "背包道具使用 の 返回")
@OperationSetter(value = GDOperation.USE_PROP)
public class PropUseReq implements MsgInput {
    @NoteField(value = "物品大类")
    public byte type;

    @NoteField(value = "物品唯一ID", detail = "传了唯一id后 模板id就不用传了")
    public String uid;

    @NoteField(value = "模板ID")
    public int tid;

    @NoteField(value = "使用数量")
    public int num;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        if (StringUtils.isBlank(uid)) {
            // 根据tid来使用
            cc.getRole().getBag().useByTid(type, tid, num);
        } else {
            // 根据idHex来使用
            cc.getRole().getBag().useByUid(type,uid);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBBag.ITEM_USE_REQ;
    }

}
